package com.ustb.springboot.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ustb.springboot.entity.QuestionRadioEntity;
import com.ustb.springboot.service.QuestionRadioService;
import com.ustb.springboot.common.utils.R;

import javax.servlet.http.HttpServletRequest;


/**
 * @author pyn
 * @date 2022-05-17 11:26:55
 */
@RestController
@RequestMapping("questionradio")
public class QuestionRadioController {
    @Autowired
    private QuestionRadioService questionRadioService;


    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("questionradio:save")
    public R save(HttpServletRequest request, @RequestBody QuestionRadioEntity questionRadio) {
        return questionRadioService.save(request, questionRadio);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("questionradio:update")
    public R update(@RequestBody QuestionRadioEntity questionRadio) {
        return questionRadioService.updateById(questionRadio) ? R.ok(20000, "更新成功") : R.error(2000, "更新失败");
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("questionradio:delete")
    public R delete(@RequestBody Map<String, Object> body) {
        return questionRadioService.remove(body);
    }

}
